package com.kc.web.controller.business;

import com.kc.business.domain.BizPublicPlace;
import com.kc.business.domain.BizPublicPlaceType;
import com.kc.business.domain.dto.BizPublicPlaceDTO;
import com.kc.business.service.IBizPublicPlaceService;
import com.kc.business.service.IBizPublicPlaceTypeService;
import com.kc.common.annotation.Log;
import com.kc.common.annotation.RepeatSubmit;
import com.kc.common.core.controller.BaseController;
import com.kc.common.core.domain.AjaxResult;
import com.kc.common.core.page.TableDataInfo;
import com.kc.common.enums.BusinessType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


import javax.annotation.Resource;

/**
 * 公共场所管理
 */
@RestController
@RequestMapping("/business/publicPlace")
public class BizPublicPlaceController extends BaseController {
    @Resource
    private IBizPublicPlaceTypeService bizPublicPlaceTypeService;
    @Resource
    private IBizPublicPlaceService bizPublicPlaceService;
    /**
     * 类别列表
     * @param bizPublicPlaceType
     * @return
     */
    @PreAuthorize("@ss.hasPermi('business:publicPlace:typeList')")
    @GetMapping(value = "/typeList")
    public TableDataInfo typeList(BizPublicPlaceType bizPublicPlaceType){
        return getDataTable(bizPublicPlaceTypeService.getList(bizPublicPlaceType));
    }

    /**
     * 新增
     */
    @RepeatSubmit
    @Log(title = "新增场所", businessType = BusinessType.INSERT)
    @PreAuthorize("@ss.hasPermi('business:publicPlace:add')")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody @Validated  BizPublicPlace bizPublicPlace){
        bizPublicPlaceService.add(bizPublicPlace);
        return AjaxResult.success();
    }
    /**
     * 新增
     */
    @RepeatSubmit
    @Log(title = "修改场所", businessType = BusinessType.UPDATE)
    @PreAuthorize("@ss.hasPermi('business:publicPlace:update')")
    @PutMapping("/update")
    public AjaxResult update(@RequestBody @Validated  BizPublicPlace bizPublicPlace){
        bizPublicPlaceService.update(bizPublicPlace);
        return AjaxResult.success();
    }

    @PreAuthorize("@ss.hasPermi('business:publicPlace:getList')")
    @GetMapping("/getList")
    public TableDataInfo getList(BizPublicPlaceDTO bizPublicPlaceDTO){
        startPage();
        return getDataTable(bizPublicPlaceService.getList(bizPublicPlaceDTO));
    }


}
